package com.bee.剑指offer;

/**
 * @version 1.0.0
 * @Author yong.Mr
 * @data 2021-04-18
 */
public class 整数中1出现的次数 {

    public int NumberOf1Between1AndN_Solution(int n) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            String str = String.valueOf(i);
            char[] chars = str.toCharArray();
            for (int j = 0; j < chars.length; j++) {
                if (chars[j] == '1') {
                    count++;
                }
            }
        }
        return count;
    }


    public static void main(String[] args) {

    }
}
